$(document).ready(function(){
    $(".select_all").click(function(){
	$(".resultTable .check_select_item").attr("checked", 'true');

	// update the selected users
	var user_list = new Array();
	$(".check_select_user:checked").each(function(i){
	    user_list[i] = $(this).attr("user_id");
	});
	$(".batch-user-id").val(user_list.join(','));

	return false;
    });
    $(".diselect_all").click(function(){
	$(".resultTable .check_select_item").removeAttr("checked");

	// clear all the selected users
	$(".batch-user-id").val('');
	return false;
    });

    $(".batch-operate").click(function(){
	var users = $(".batch-user-id").val();
	if (!users)
	{
	    alert("你没有选择用户");
	    return false;
	}
	return confirm("你确定要进行此操作吗？")
    });

    $(".check_select_user").click(function(){
	// update the selected users
	var user_list = new Array();
	$(".check_select_user:checked").each(function(i){
	    user_list[i] = $(this).attr("user_id");
	});
	$(".batch-user-id").val(user_list.join(','));
    });
    $(".delete-link").click(function(){
	var name=$(this).attr("name");
	return confirm("你确定要删除\""+name+"\"吗？");
    });

});